Global Variables

To get around the local variable problem, you can create a global variable. Global variables are declared outside a function and are visible throughout the entire script. You declare global variables outside a function using the keyword global. For example:

global GVar

or

global GVar = 5

Using global variables, you can keep status information past the end of a function. Making RepRate a global variable fixes the problem described under Local Variables:

global RepRate

 

function SetSpeed(NewValue)

if (NewValue ne NIL)

RepRate = NewValue

else

RepRate = RepRate+1

return

 

function Main()

SetSpeed(1)

while (RunExperiment() eq 0) ; return of zero = experiment was ok

SetSpeed(NIL) ; go faster by incrementing RepRate

... ; continue after loop